package com.gxdf.uc.data;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.content.Context;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.widget.LinearLayout;

public abstract class GxdfField extends LinearLayout {	
	
	Field field;	
	List<String> actualValues;
	List<ValidationResult> validRules;
	Pattern pattern;
	Matcher matcher;
	
	public GxdfField(Context context, Field field) {
		super(context);
		this.field = field;
		actualValues= new ArrayList<String>();
		validRules = new ArrayList<ValidationResult>();
	}	
	
	public Field getField() {
		return field;
	}

	public void setField(Field field) {
		this.field = field;
	}

	public String getFieldName(){
		return field.name;
	}
	
	protected boolean errorRequired(){		
		return (actualValues.size()==0 && field.isRequired());
	}
	
	public List<ValidationResult> getValidationList(){
		return validRules;
	}
	
	protected abstract boolean errorFormat();
	protected abstract boolean errorLength();	
	public abstract boolean isFieldvalid();
	public abstract void runValidationRules();
	public abstract String getValue();
	public abstract void drawField();
	public abstract void saveValues();	
	public abstract boolean isModified();	
	public abstract List<String> getActualValues();
	
}
